**********************************************************************************************************
*This file cleans data for IT capital intensity and PC adoption. Adapted version of Pascual Restrepo, JPE*
**********************************************************************************************************

*******************************************************************************************
***Step 1: measure of share investment in IT from ASM for sic87 manufacturing industries***
*******************************************************************************************

**Project to czones using CBP baseline employment shares**
use "$contributed_data/cbp_by_industry1980.dta", clear
rename sic4 sic87
do "$project/xwalks/xwalks_industry/subfile_sic87dd.do"

* merge ASM data by industry *
merge m:1 sic87dd using "$contributed_data/computer_use_solow.dta", nogenerate assert(1 3)

gen share_ind=imp_emp/tot_emp_cz

foreach year in 1977 1982 1987 1992 2002 2007 {
	gen expo_it_intensity_`year'=ci`year' /*share (in pp) of investment in IT technologies*/
}

* Following ADH, this step assumes no exposure outside of manufacturing *
collapse (sum) expo_* [iw=share_ind], by(czone)
save "$clean_data_automation/expo_it_computers.dta", replace

*******************************************************************************************
***Step 1: measure of share investment in IT from ASM for sic87 manufacturing industries***
*******************************************************************************************

**Project to czones using Census employment shares for IFR industries**
use "$clean_data_lmarket/czone_1970_emp_by_ifr19.dta", clear

* merge CPS data on computer use by industry *
merge m:1 industry_ifr using "$contributed_data/computer_use_cps.dta", nogenerate assert(1 3)

gen expo_comp_intensity_1993=100*use1993 /*share (in pp) of employees using computers at work*/

gen expo_comp_intensity_1989=100*use1989 
gen expo_comp_intensity_1997=100*use1997
gen expo_comp_intensity_2001=100*use2001
gen expo_comp_intensity_2003=100*use2003

collapse (mean) expo_* [w=emppriv], by(czone)

* merge ASM data and fill it in for czones with no manufacturing employment *
merge 1:1 czone using "$clean_data_automation/expo_it_computers.dta", nogenerate

foreach year in 1977 1982 1987 1992 2002 2007 {
	replace expo_it_intensity_`year'=0 if expo_it_intensity_`year'==.
}

save "$clean_data_automation/expo_it_computers.dta", replace
